
let ev=require("./getConfig").ev;
let config1 = require(ev.path);
let createUdp = require("./createUdp.js").createUdp;
function initServer() {
    if (global.borderServer) {
        return global.borderServer;
    }
   let borderServer = createUdp(0, "0.0.0.0",function(){
  /* setTimeout(function(){*/
 //   borderServer.setBroadcast(1);//开启广播
  //  borderServer.setTTL(128);
 /*  }.bind(this),Math.random()*5000)*/
   });
    return borderServer;
}
let Broadport=ev.Broadport||config1.Broadport;
console.log(">>端口"+Broadport)
function sendBroad(msg) {
  let  server = initServer();
    server.send(msg, Broadport, config1.Broadip);
}
function sendbroadByport(msg, port) {
  let  server = initServer();
    server.send(msg, port, config1.Broadip);
   /* body... */ 
}
global.borderServer=initServer();// 初始化
console.log("borad..");
sendBroad(`server,go:${config1.go}`);
module.exports.sendBroad = sendBroad;
module.exports.sendbroadByport=sendbroadByport;